<?php

if (validation_errors()) :
?>
<section class="content-header">
<div class='alert alert-block alert-error fade in'>
    <a class='close' data-dismiss='alert'>&times;</a>
    <h4 class='alert-heading'>
        <?php echo lang('category_errors_message'); ?>
    </h4>
    <?php echo validation_errors(); ?>
</div>
</section>
<?php
endif;

$id = isset($category->tag_id) ? $category->tag_id : '';

?>

<!-- Main content -->
<section class="content">
  <div class="row">
    <div class="col-xs-12">
        <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title">新增<?php echo lang('category_area_title'); ?></h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <?php echo form_open($this->uri->uri_string(), 'class="form-horizontal"'); ?>
              <div class="box-body">
                <div class="form-group">
                  <?php echo form_label(lang('category_field_tag_name') . lang('bf_form_label_required'), 'tag_name', array('class'=>'col-sm-2 control-label')); ?>
                  <div class="col-sm-10">
                  <input id='tag_name' type='text' required='required' name='tag_name' class="form-control" maxlength='100' value="<?php echo set_value('tag_name', isset($category->tag_name) ? $category->tag_name : ''); ?>"/>
                  </div>
                </div>
                <div class="form-group">
                <?php echo form_label('别名' . lang('bf_form_label_required'), 'url_str', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10">
                    <input id='url_str' type='text' name='url_str' required='required' maxlength='100' class="form-control" value="<?php echo set_value('url_str', isset($category->url_str) ? $category->url_str : ''); ?>" placeholder="“别名”是在URL中使用的别称，通常使用小写，可以包含字母和数字" />
                    </div>
                </div>
                <div class="form-group">
                <?php echo form_label('父级', 'parent_id', array('class'=>'col-sm-2 control-label')); ?>
                    <div class="col-sm-10">
                        <select class="form-control select2" style="width: 100%;" name="parent_id" id="parent_id">
                          <option selected="selected" value="0">可选择父级</option>
                          <?php foreach ($categories as $one) : ?>
                          <option value="<?php echo $one->tag_id; ?>" <?php if ($one->tag_id==$category->parent_id) : ?>selected<?php endif; ?>><?php echo $one->tag_name; ?></option>
                        <?php endforeach; ?>
                        </select>
                    </div>
                </div>
               <div class="form-group">
                  <?php echo form_label("启用", 'status', array('class' => 'col-sm-2 control-label')); ?>
                  <div class="col-sm-10">
                     <input id='status' class="minimal" type='checkbox'  name='status'  value="1"   <?php if ($category->status == 1) : ?> checked <?php endif; ?> />
                </div>
            </div>
              </div>
              <!-- /.box-body -->

              <div class="box-footer">
                <button type="submit" name='save' class="btn btn-primary">Submit</button>
                <?php echo anchor(SITE_AREA . '/content/category', lang('category_cancel'), 'class="btn btn-default pull-right"'); ?>
              </div>
            <?php echo form_close(); ?>
          </div>

          </div>
      </div>
</section>